--- %%NOBANNER%% -->
![]() | ![]() |
/*------------------<--- Start of Description -->--------------------\ | Power for one proportion; | |--------------------<--- End of Description -->---------------------| |--------------------------------------------------------------------| |--------------<--- Start of Files or Arguments Needed -->-----------| | Arguements: | | - Required: | | n1 = sample size | | y1 = true proportion under null hypothesis, 0------------| |--------------------------------------------------------------------| |----------------<--- Start of Example and Usage -->-----------------| | Example: %prop1_pr(sides=1,y1=.3,n1=30,min_y2=.3,max_y2=.9, | | inc_y2=.1,plot=p); | | Usage: %prop1_pr(ALPHA=.05,SIDES=2,Y1=.,MIN_Y2=.,MAX_Y2=., | | INC_Y2=.,N1=., PLOT= ); | | Reference: Bergstralh, EJ. SAS macros for sample size and power | | calculations. Proceedings of the 9th annual SAS Users | | Group International Conference. | | Equation #'s 11 and 12. | \-------------------<--- End of Example and Usage -->---------------*/ %MACRO prop1_pr(ALPHA=.05,SIDES=2,Y1=.,MIN_Y2=.,MAX_Y2=., INC_Y2=.,N1=., PLOT= ); /*--------------------------------------------\ | Author: Michael Riggs and Eric Bergstralh; | | Purpose: Power for one proportion; | \--------------------------------------------*/ OPTIONS MISSING=' ' NOCENTER; %LET PLOT=%UPCASE(&PLOT); DATA T1; ALPHA=&ALPHA; SIDES=&SIDES; Y1=&Y1; MIN_Y2=&MIN_Y2; MAX_Y2=&MAX_Y2; INC_Y2=&INC_Y2; N1=&N1; ZALPHA=(PROBIT(1-ALPHA))*(SIDES=1) + (PROBIT(1-ALPHA/2))*(SIDES=2); IF MAX_Y2=. THEN DO; MAX_Y2=MIN_Y2+1; INC_Y2=MIN_Y2+2; *NEED 1 EXEC OF DO; END; TN1=N1; TY1=Y1; DO Y2=MIN_Y2 TO MAX_Y2 BY INC_Y2; *NORMAL APPROX. TO BINOMIAL; ZB_NL=( SQRT(TN1)*ABS(Y2-TY1)-ZALPHA*SQRT(TY1*(1-TY1))) / SQRT(Y2*(1-Y2)) ; PR_NML=PROBNORM(ZB_NL); *NORMAL APPROX. FOLLOWING 2*ARCSIN(SQRT(PROP.)) TRANSFORMATION; AS_Y1=2*ARSIN(SQRT(TY1)); AS_Y2=2*ARSIN(SQRT(Y2)); ZB_AS=SQRT(TN1)*ABS(AS_Y2-AS_Y1)-ZALPHA; PR_ARS=PROBNORM(ZB_AS); OUTPUT; END; LABEL Y1='Null hyp.*Proportion' Y2='Alt. hyp.*Proportion' PR_NML='POWER*(Binomial @)' PR_ARS='POWER*(Arcsin @@)'; RUN; PROC PRINT SPLIT='*'; ID y1; VAR Y2 PR_NML PR_ARS ; TITLE3 "POWER ESTIMATES FOR ONE PROPORTION"; TITLE4 "Alpha=&alpha, Sides=&sides, Sample size=&n1, Null hypothesis prop.=&y1"; FOOTNOTE1 '@, Normal approximation to binomial.'; FOOTNOTE2 '@@, Arcsin transformation followed by normal approximation.'; %if &max_y2 ne . %then %do; %if &plot= P %then %do; PROC PLOT NOLEGEND; PLOT PR_NML*Y2='N' PR_ARS*Y2='A' / OVERLAY; LABEL PR_NML='POWER' Y2='Alt. hypothesis proportion'; FOOTNOTE1 'N=Normal approximation to binomial'; FOOTNOTE2 'A=Arcsin transformation followed by normal approximation'; %end; %else %if &plot= G %then %do; PROC GPLOT; PLOT PR_NML*Y2 PR_ARS*Y2/OVERLAY HAXIS=AXIS2 VAXIS=AXIS1; SYMBOL1 F=SPECIAL V=K H=1 I=j l=2; SYMBOL2 F=SPECIAL V=M H=1 i=j l=1; LABEL PR_NML='POWER' Y2='Alt. hypothesis proportion'; FOOTNOTE1 F=SPECIAL ' ' M=(+6,-.7) H=2 'K' F=TRIPLEX H=1 M=(-.5,+.3) ' Normal approx. to binomial' F=SPECIAL M=(+6 -.4) H=2.0 'M' F=TRIPLEX H=1 M=(-.5,+.4) ' Normal approx. with arcsin'; run; %END; RUN; %END; %MEND prop1_pr;